package com.garen.fire.biz.impl;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.garen.common.MsgBean;
import com.garen.common.PageBean;
import com.garen.fire.biz.IFireCarBiz;
import com.garen.fire.biz.IFireCaseInfoBiz;
import com.garen.fire.dao.IFireCarDao;
import com.garen.fire.entity.FireCar;
import com.garen.fire.web.FireDutyAction;


@Service
public class FireCarBizImpl implements IFireCarBiz {


	protected static Log log = LogFactory.getLog(FireDutyAction.class);

	
	@Autowired
	private IFireCarDao fireCarDao;

	@Autowired
	private IFireCaseInfoBiz iFireCaseInfoBiz;

	//查询派遣车辆
	@Override
	public List<Map<String,Object>> getSendFireCar(String ajbh) {
		List<Map<String,Object>>  carlist = fireCarDao.findFireCarByAjbh(ajbh);;
		if(carlist.isEmpty()) {
			//抓取天威尔派遣车辆
			Set<String> carSet = iFireCaseInfoBiz.fetchCaseCars(ajbh);
			if(false == carSet.isEmpty())
				carlist = fireCarDao.findFireCarByUUID(carSet);
		}
		log.debug("获取派遣消防车:" + carlist);
		return carlist;
	}
	//查询派遣车辆
		@Override
		public List<Map<String, Object>> getcarcount(String org_id) {
			
			return fireCarDao.getcarcount(org_id);
		}
	/*
	*分页查询
	*/
	@Override
	public List<FireCar> getFireCarList(PageBean<FireCar> pb,FireCar fireCar){
		return fireCarDao.getPageList(pb,fireCar);
	}

	/*
	*分页查询
	*/
	@Override
	public List<FireCar> getFireCarList(FireCar fireCar){
		return fireCarDao.getList(fireCar);
	}

	/*
	*查询个体
	*/
	@Override
	public FireCar getFireCar(FireCar fireCar){
		return fireCarDao.get(fireCar);
	}

	/*
	*保存
	*/
	@Override
	public int saveFireCar(MsgBean mbean,FireCar fireCar){
		int ret = -1;
		if(fireCar.getCarId() == null){
			ret = fireCarDao.add(fireCar);
		}else{
			ret = fireCarDao.update(fireCar);
		}
		return ret;
	}

	/*
	*删除
	*/
	@Override
	public int delFireCar(MsgBean mbean,FireCar fireCar){
		return fireCarDao.del(fireCar);
	}

}
